package org.lwxyz.api;

import org.lwxyz.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yuwei
 * @version 1.0-SNAPSHOT
 * @description
 * @date
 */
@RestController
public class RedisController {
    @Autowired
    private RedisService redisService;

    @RequestMapping(value = "/count-task")
    public String redis(){
        System.out.println(redisService.redis());
        return redisService.redis();
    }

    @RequestMapping(value = "/count-task-add")
    public String setValue(@RequestParam(value = "key")String key, @RequestParam(value = "value")String value){
        String result = redisService.add(key, value);
        if ("no".equals(result)) {
            return "最多只能添加10个.";
        }
        return "ok";
    }

    @RequestMapping(value = "/count-delete")
    public String delete(@RequestParam(value = "id")String id){
        redisService.delete(id);
        return "ok";
    }
}
